import table from '@/components/dt/table/render.js'
import clueCustomerMgr from '@/biz/customer/clueCustomer.js'

function options1(_this) {
  return [
    {
      field: '',
      title: '霸屏神器预览',
      minWidth: 150,
      slots: {
        default: (params, h) => {
          let img = {
            event: 'seeBg',
            src: params.row.previewUrl ? params.row.previewUrl : '',
            data: params.row.previewUrl
          }
          return params.row.previewUrl ? table.cell.img(_this, h, img, false) : '-'
        }
      }
    },
    {
      field: 'title',
      title: '霸屏神器名',
      minWidth: 180
    },
    {
      field: 'scanCodeType',
      title: '扫码落地页',
      minWidth: 150,
      header: {
        filter: {
          title: '扫码落地页',
          key: 'scanCodeType',
          placeholder: '请选择',
          select: {
            options: [
              {
                key: 'ONLINE_SALE_OFFICE',
                value: '线上售楼处'
              }
              // {
              //   key: 2,
              //   value: '抽奖活动'
              // }
            ]
          }
        }
      }
      // slots: {
      //   default: (params, h) => {
      //     return [h('div', params.row.scanCodeType == 'ONLINE_SALE_OFFICE' ? '线上售楼处' : '抽奖')]
      //   }
      // }
    },

    {
      field: 'quoteCount',
      title: '推广次数',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'quoteCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'scanCount',
      title: '扫码次数',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'scanCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'addClueCount',
      title: '新增线索',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'addClueCountSort',
        desc: '2',
        asc: '1'
      }
    },

    {
      field: 'createDate',
      title: '创建时间',
      minWidth: 160
    },
    {
      title: '创建人',
      minWidth: 180,
      cell: {
        value: (row) => {
          return `${row.userName ? (row.workNo ? row.userName + '(' + row.workNo + ')' : row.userName) : '-'}`
        },
        text: {}
      }
    },
    {
      field: 'saleOfficeText',
      title: '线上售楼处展示',
      minWidth: 150,
      header: {
        filter: {
          title: '线上售楼处展示',
          key: 'saleOffice',
          placeholder: '请选择',
          select: {
            options: [
              {
                key: 0,
                value: '否'
              },
              {
                key: 1,
                value: '是'
              }
            ]
          }
        }
      }
      // slots: {
      //   default: (params, h) => {
      //     return [h('div', params.row.saleOffice == 0 ? '隐藏' : '展示')]
      //   }
      // }
    },
    {
      field: 'readCount',
      title: '线上售楼处阅读数',
      minWidth: 180,
      remoteSort: true,
      sort: {
        key: 'readCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'handles',
      title: '操作',
      minWidth: 100,
      fixed: 'right',

      slots: {
        default: (params, h) => {
          let btns = []
          let item = params.row
          btns.push({
            title: _this.unlocking('0107080102') && params.row.templateId ? '编辑' : '',
            event: _this.unlocking('0107080102') && params.row.templateId ? 'articleAddEdit' : '',
            data: ['edit', item]
          })
          btns.push({
            title: _this.unlocking('0107080103') ? '删除' : '',
            event: _this.unlocking('0107080103') ? 'delShort' : '',
            data: item
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }
  ]
}
function options2(_this) {
  return [
    {
      field: '',
      title: '海报预览',
      minWidth: 150,
      slots: {
        default: (params, h) => {
          let img = {
            event: 'seeBg',
            src: params.row.previewUrl ? params.row.previewUrl : '',
            data: params.row.previewUrl
          }
          return params.row.previewUrl ? table.cell.img(_this, h, img, false) : '-'
        }
      }
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 180
    },
    {
      title: '创建人',
      minWidth: 180,
      cell: {
        value: (row) => {
          return `${row.userName ? (row.workNo ? row.userName + '(' + row.workNo + ')' : row.userName) : '-'}`
        },
        text: {}
      }
    },

    {
      field: 'scanCodeType',
      title: '扫码落地页',
      minWidth: 150,
      header: {
        filter: {
          title: '扫码落地页',
          key: 'scanCodeType',
          placeholder: '请选择',
          select: {
            options: [
              {
                key: 'ONLINE_SALE_OFFICE',
                value: '线上售楼处'
              }
              // {
              //   key: 2,
              //   value: '抽奖活动'
              // }
            ]
          }
        }
      }
      // slots: {
      //   default: (params, h) => {
      //     return [h('div', params.row.scanCodeType == 'ONLINE_SALE_OFFICE' ? '线上售楼处' : '抽奖')]
      //   }
      // }
    },

    {
      field: 'quoteCount',
      title: '推广次数',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'quoteCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'scanCount',
      title: '扫码次数',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'scanCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'addClueCount',
      title: '新增线索',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'addClueCountSort',
        desc: '2',
        asc: '1'
      }
    },

    {
      field: 'handles',
      title: '操作',
      minWidth: 150,
      fixed: 'right',

      slots: {
        default: (params, h) => {
          let btns = []
          let item = params.row
          btns.push({
            title: _this.unlocking('0107080202') ? '编辑' : '',
            event: _this.unlocking('0107080202') ? 'placardAddEdit' : '',
            data: ['edit', item]
          })
          btns.push({
            title: _this.unlocking('0107080203') ? '删除' : '',
            event: _this.unlocking('0107080203') ? 'delPlacard' : '',
            data: item
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }
  ]
}
function options3(_this) {
  return [
    {
      field: '',
      title: '海报预览',
      minWidth: 150,
      slots: {
        default: (params, h) => {
          let img = {
            event: 'seeBg',
            src: params.row.posterUrl ? params.row.posterUrl : '',
            data: params.row.posterUrl
          }
          return params.row.posterUrl ? table.cell.img(_this, h, img, false) : '-'
        }
      }
    },
    {
      field: 'createDate',
      title: '创建时间',
      minWidth: 160
    },
    {
      field: 'userName',
      title: '创建人',
      minWidth: 180,
      header: {
        filter: {
          title: '创建人',
          key: 'userId',
          placeholder: '请选择创建人',
          load: (o) => {
            o.select.options = clueCustomerMgr.selectTeamUser()
          },
          select: {
            options: [],
            multiple: false,
            filterable: true,
            remote: (key) => {
              return clueCustomerMgr.selectTeamUser(key)
            }
          }
        }
      },
      cell: {
        value: (row) => {
          return `${row.userName ? (row.workNo ? row.userName + '(' + row.workNo + ')' : row.userName) : '-'}`
        },
        text: {}
      }
    },
    {
      field: 'quoteCount',
      title: '推广次数',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'quoteCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'scanCount',
      title: '扫码次数',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'scanCountSort',
        desc: '2',
        asc: '1'
      }
    },
    {
      field: 'addClueCount',
      title: '新增线索',
      minWidth: 150,
      remoteSort: true,
      sort: {
        key: 'addClueCountSort',
        desc: '2',
        asc: '1'
      }
    }
  ]
}
export default {
  options1,
  options2,
  options3
}
